//
//  ViewController.m
//  Dayou
//
//  Created by mac on 2018/7/31.
//  Copyright © 2018年 YangYang. All rights reserved.
//

#import "ViewController.h"
#import "VideoMenuViewController.h"
#import "BaseItemViewController.h"


@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *dataSource;


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTable];
}

-(void)createTable
{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.tableFooterView = [UIView new];
    
}

#pragma mark - ----------------------UITableViewDataSource----------------------
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (self.dataSource.count > indexPath.row) {
        cell.textLabel.text = self.dataSource[indexPath.row];
    }
    return cell;
}

#pragma mark - ----------------------UITableViewDelegate----------------------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch (indexPath.row) {
        case 0:
        {//视频播放
            VideoMenuViewController *videoMenuVC = [[VideoMenuViewController alloc] init];
            videoMenuVC.navigationItem.title = @"视频播放菜单";
            [self.navigationController pushViewController:videoMenuVC animated:YES];
        }
            break;
        case 1:
        {//悬浮标签
            BaseItemViewController *baseItemVC = [BaseItemViewController suspendTopPageVC];
            baseItemVC.navigationItem.title = @"标签悬浮";
            [self.navigationController pushViewController:baseItemVC animated:YES];
        }
            break;
            
        default:
            break;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}

-(NSArray *)dataSource
{
    if (!_dataSource) {
        _dataSource = @[@"视频播放",@"悬浮标签"];
    }
    return _dataSource;
}


//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//    NormalVideoViewController *normalVideoVC = [[NormalVideoViewController alloc] init];
//    normalVideoVC.navigationItem.title = @"普通样式";
//    [self.navigationController pushViewController:normalVideoVC animated:YES];
//}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end







































////
////  ViewController.m
////  Dayou
////
////  Created by mac on 2018/7/31.
////  Copyright © 2018年 YangYang. All rights reserved.
////
//
//#import "ViewController.h"
//#import <SDCycleScrollView.h>
//
//#import "YNPageViewController.h"
//
//#import "BaseItemViewController.h"
//
//
//@interface ViewController ()
//
//
//@end
//
//@implementation ViewController
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//
//
//}
//
//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
//{
//
//
//    BaseItemViewController *baseItemVC = [BaseItemViewController suspendTopPageVC];
//
//    [self.navigationController pushViewController:baseItemVC animated:YES];
//}
//
//
//
//
//
//
//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
//
//@end






































////
////  ViewController.m
////  Dayou
////
////  Created by mac on 2018/7/31.
////  Copyright © 2018年 YangYang. All rights reserved.
////
//
//#import "ViewController.h"
//#import "ImageBgView.h"
//
//
//@interface ViewController ()<TZImagePickerControllerDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate>
//
//@property (nonatomic, strong) UITextField *namefield;
//@property (nonatomic, strong) ImageBgView *imageBgView;
//
//@property (nonatomic, strong) NSMutableArray *selectAssets;
//@property (nonatomic, strong) NSMutableArray *selectImageArr;
//
//
//@end
//
//@implementation ViewController
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    UIButton *pickerBtn = [UIButton buttonWithType:UIButtonTypeContactAdd];
//    [self.view addSubview:pickerBtn];
//    [pickerBtn addTarget:self action:@selector(selectPictureAction) forControlEvents:UIControlEventTouchUpInside];
//    [pickerBtn makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.view.mas_left).offset(10);
//        make.top.equalTo(self.view.top).offset(10);
//        make.width.equalTo(100);
//        make.height.equalTo(100);
//    }];
//
//    _imageBgView = [[ImageBgView alloc] init];
//    [self.view addSubview:_imageBgView];
//    _imageBgView.width = (ScreenWidth - 20) / 4;
//    [_imageBgView makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(pickerBtn.left).offset(0);
//        make.top.equalTo(pickerBtn.bottom).offset(0);
//        make.width.equalTo(ScreenWidth - 20);
////        make.height.equalTo(400);
//    }];
//
//    _imageBgView.imageViewBlock = ^(NSArray *imageArr) {
//        NSLog(@"imageArr = %@",imageArr);
//    };
//
//}
//
//-(void)selectPictureAction
//{
//    UIAlertAction *takePhotoAction = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        [self takePhotoAction];
//    }];
//    UIAlertAction *albumAction = [UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        [self albumAction];
//
//    }];
//    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//
//    }];
//
//    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
//    [alertController addAction:takePhotoAction];
//    [alertController addAction:albumAction];
//    [alertController addAction:cancelAction];
//
//    [self presentViewController:alertController animated:YES completion:nil];
//}
//
//-(void)albumAction
//{
//    TZImagePickerController *pickerController = [[TZImagePickerController alloc] initWithMaxImagesCount:9 delegate:self];
//
//    [self presentViewController:pickerController animated:YES completion:nil];
//}
//
//-(void)takePhotoAction
//{
//    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
//    //判断设备是否支持拍照功能
//    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
//    {
//        NSLog(@"该设备支持拍照功能");
//        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
//        picker.delegate = self;
//        //设置拍照后的图片可被编辑
//        //        picker.allowsEditing = YES;
//        picker.sourceType = sourceType;
//        [self presentViewController:picker animated:YES completion:nil];
//    }
//    else
//    {
//
//    }
//}
//
//- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos
//{
//    NSLog(@"photos = %@",photos);
//    _imageBgView.imageArr = photos;
//    [_imageBgView refreshUI];
//}
//
//- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary<NSString *,id> *)editingInfo NS_DEPRECATED_IOS(2_0, 3_0)
//{
//    [self dismissViewControllerAnimated:YES completion:nil];
//
//
//}
//- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
//{
//
//    [self dismissViewControllerAnimated:YES completion:nil];
//
//    NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
//    if ([type isEqualToString:@"public.image"])
//    {
//        [picker dismissViewControllerAnimated:YES completion:nil];
//        NSLog(@"成功更换图片：info = %@",info);
//        UIImage *Image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
//        if (self.imageArr.count < 9) {
//            [self.imageArr addObject:Image];
//            [self updateImageBgView:self.imageArr];
//        }
//
//        ////////////////////////////////////////////////////
//
//        [[TZImageManager manager] savePhotoWithImage:Image completion:^(NSError *error) {
//            [[TZImageManager manager] getCameraRollAlbum:NO allowPickingImage:YES completion:^(TZAlbumModel *model) {
//
//                NSLog(@"[model.result class] = %@",[model.result class]);
//
//                [[TZImageManager manager] getAssetsFromFetchResult:model.result allowPickingVideo:NO allowPickingImage:YES completion:^(NSArray<TZAssetModel *> *models) {
//                    NSLog(@"models = %@",models);
//                    NSLog(@"[models count] = %ld",[models count]);
//                    TZAssetModel *assetModel = [models lastObject];
//                    PHAsset *asset = assetModel.asset;
//                    NSLog(@"[assetModel.asset class] = %@",[assetModel.asset class]);
//                    [self.selectedAssets addObject:assetModel.asset];
//                }];
//            }];
//        }];
//}
//- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
//{
//    [self dismissViewControllerAnimated:YES completion:nil];
//}
//
//-(NSMutableArray *)selectAssets
//{
//    if (!_selectAssets) {
//        _selectAssets = [NSMutableArray new];
//    }
//    return _selectAssets;
//}
//
//-(NSMutableArray *)selectImageArr
//{
//    if (!_selectImageArr) {
//        _selectImageArr = [NSMutableArray new];
//    }
//    return _selectImageArr;
//}
//
//
//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
//
//@end
